#老师有年龄，学校，姓名的属性，有上课和自我介绍的方法，如果年龄少于22岁，抛出异常。
import  traceback
class Teacher():
     def __init__(self,name,school_name,age):
         self.name=name
         self.school_name = school_name
         self.age = age
     def shangke(self):
         print("同学们，开始上课了！")
     def intro_myself(self):
         print(f"我的名字是{self.name},今年{self.age}岁，现在在{self.school_name}当数学老师")

if __name__ == '__main__':

     teacher=Teacher("张三","合肥一中",23)
     try:
         if teacher.age <22:
             raise ValueError("老师的年龄不符合规定！请重新录入")
         teacher.intro_myself()
         teacher.shangke()
     except    ValueError as e:
         print(e)


